// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asSerializedAttribute.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the SerializedAttributes class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asEntity.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "asSerializable.h"
#include "../ScriptHelper.h"

#include "../../core/SerializedAttributes.h"


//! Reference factory for the SerializedAttributes class.
SerializedAttributes* createSerializedAttributes()
{
    return new SerializedAttributes();
}

//! Wrapper function to allow classes "derived" from the Serializable class to be
//! used by the SerializedAttributes::pushObject.
void pushObject(const std::string &name, asIScriptObject *object, SerializedAttributes *pAttributes)
{
    ScriptedSerializable *serializable = new ScriptedSerializable(object);
    pAttributes->pushObject(name, serializable);
    serializable->drop();
}


//! Binds the SerializedAttributes class to AngelScript.
void bindSerializedAttributes(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind SerializedAttributes class (and dependencies).
    r = engine->RegisterObjectType("SerializedAttributes", sizeof(SerializedAttributes), asOBJ_REF);

    // Bind inherited functions.
    bindSerializableBase<SerializedAttributes>(engine, "SerializedAttributes");

    // Set SerializedAttributes behaviour.
    r = engine->RegisterObjectBehaviour("SerializedAttributes", asBEHAVE_FACTORY, "SerializedAttributes@ f()",
                                        asFUNCTION(createSerializedAttributes), asCALL_CDECL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttributes", "SerializedAttributes& opAssign(const SerializedAttributes &in)",
                                        asFUNCTION(assignT<SerializedAttributes>), asCALL_CDECL_OBJLAST); assert(r >= 0);

    // Bind SerializedAttributes class functions.
    r = engine->RegisterObjectMethod("SerializedAttributes", "bool isEmpty()",
                                     asMETHOD(SerializedAttributes, isEmpty), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttributes", "SerializedAttribute@ pullAttribute()",
                                     asMETHOD(SerializedAttributes, pushAttribute), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttributes", "aabbox3df    pullAabbox3df()",
                                     asMETHOD(SerializedAttributes, pullAabbox3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "aabbox3di    pullAabbox3di()",
                                     asMETHOD(SerializedAttributes, pullAabbox3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "bool         pullBool()",
                                     asMETHOD(SerializedAttributes, pullBool), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "SColor       pullColor()",
                                     asMETHOD(SerializedAttributes, pullColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "dimension2df pullDimension2df()",
                                     asMETHOD(SerializedAttributes, pullDimension2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "dimension2di pullDimension2di()",
                                     asMETHOD(SerializedAttributes, pullDimension2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "f32          pullFloat()",
                                     asMETHOD(SerializedAttributes, pullFloat), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "s32          pullInt()",
                                     asMETHOD(SerializedAttributes, pullInt), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "line2df      pullLine2df()",
                                     asMETHOD(SerializedAttributes, pullLine2df), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "line2di      pullLine2di()",
                                     asMETHOD(SerializedAttributes, pullLine2di), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "line3df      pullLine3df()",
                                     asMETHOD(SerializedAttributes, pullLine3df), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "line3di      pullLine3di()",
                                     asMETHOD(SerializedAttributes, pullLine3di), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "Serializable@ pullObject()",
                                     asMETHOD(SerializedAttributes, pullObject), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "recti        pullRect()",
                                     asMETHOD(SerializedAttributes, pullRect), asCALL_THISCALL); assert(r >= 0);
	r = engine->RegisterObjectMethod("SerializedAttributes", "string       pullString()",
                                     asMETHOD(SerializedAttributes, pullString), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "vector2df    pullVector2df()",
                                     asMETHOD(SerializedAttributes, pullVector2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "vector2di    pullVector2di()",
                                     asMETHOD(SerializedAttributes, pullVector2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "vector3df    pullVector3df()",
                                     asMETHOD(SerializedAttributes, pullVector3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "vector3di    pullVector3di()",
                                     asMETHOD(SerializedAttributes, pullVector3di), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushAabbox3df(const string &in, const aabbox3df &in)",
                                     asMETHOD(SerializedAttributes, pushAabbox3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushAabbox3di(const string &in, const aabbox3di &in)",
                                      asMETHOD(SerializedAttributes, pushAabbox3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushBool(const string &in, bool)",
                                     asMETHOD(SerializedAttributes, pushBool), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushColor(const string &in, const SColor &in)",
                                     asMETHOD(SerializedAttributes, pushColor), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushDimension2df(const string &in, const dimension2df &in)",
                                     asMETHOD(SerializedAttributes, pushDimension2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushDimension2di(const string &in, const dimension2di &in)",
                                     asMETHOD(SerializedAttributes, pushDimension2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushFloat(const string &in, f32)",
                                     asMETHOD(SerializedAttributes, pushFloat), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushInt(const string &in, s32)",
                                     asMETHOD(SerializedAttributes, pushInt), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushLine2df(const string &in, const line2df &in)",
                                     asMETHOD(SerializedAttributes, pushLine2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushLine2di(const string &in, const line2di &in)",
                                     asMETHOD(SerializedAttributes, pushLine2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushLine3df(const string &in, const line3df &in)",
                                     asMETHOD(SerializedAttributes, pushLine3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushLine3di(const string &in, const line3di &in)",
                                     asMETHOD(SerializedAttributes, pushLine3di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushObject(const string &in, Serializable@+)",
                                     asMETHOD(SerializedAttributes, pushObject), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushObject(const string &in, ISerializable@+)",
                                     asFUNCTION(pushObject), asCALL_CDECL_OBJLAST); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushRect(const string &in, const recti &in)",
                                     asMETHOD(SerializedAttributes, pushRect), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushString(const string &in, const string &in)",
                                     asMETHOD(SerializedAttributes, pushString), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushVector2df(const string &in, const vector2df &in)",
                                     asMETHOD(SerializedAttributes, pushVector2df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushVector2di(const string &in, const vector2di &in)",
                                     asMETHOD(SerializedAttributes, pushVector2di), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushVector3df(const string &in, const vector3df &in)",
                                     asMETHOD(SerializedAttributes, pushVector3df), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("SerializedAttributes", "void pushVector3di(const string &in, const vector3di &in)",
                                     asMETHOD(SerializedAttributes, pushVector3di), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
